using System;
using System.Web.UI.WebControls;
using eWorld.UI;
using TimeSheetBLL;

namespace TimeSheet
{
    /// <summary>
    /// Summary description for PrintReport.
    /// </summary>
    public class PrintReport : TimeSheetForm
    {
        protected CheckBox cbOvertime;
        protected CalendarPopup cpStaffFrom;
        protected CalendarPopup cpStaffTo;
        protected Button btnStaffReport;
        protected CheckBox cbShowNonBillable;

        private void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                cpStaffFrom.SelectedDate = Utils.GetPreviousWeekStart(DateTime.Now);
                cpStaffTo.SelectedDate = Utils.GetPreviousWeekEnd(DateTime.Now);
            }
        }

        private string GetStaffFrom()
        {
            return Server.UrlEncode(cpStaffFrom.SelectedDate.ToString());
        }

        private string GetStaffTo()
        {
            return Server.UrlEncode(cpStaffTo.SelectedDate.ToString());
        }

        private string GetShowNonBillable()
        {
            return Server.UrlEncode(cbShowNonBillable.Checked.ToString());
        }

        private string GetShowOvertime()
        {
            return Server.UrlEncode(cbOvertime.Checked.ToString());
        }

        #region Web Form Designer generated code

        protected override void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
        }

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.btnStaffReport.Click +=
                new System.EventHandler(this.btnStaffReport_Click);
            this.Load += new System.EventHandler(this.Page_Load);
        }

        #endregion

        private void btnStaffReport_Click(object sender, EventArgs e)
        {
            Response.Redirect(
                "Protected/StaffReport.aspx?id=" + GetUser().ID +
                "&nonbillable=" + GetShowNonBillable() +
                "&from=" + GetStaffFrom() +
                "&to=" + GetStaffTo() +
                "&overtime=" + GetShowOvertime());
        }
    }
}